layui.use(['form', 'jquery', 'layer', 'table', 'laydate','upload'], function() {
	var form = layui.form;
	var $ = layui.$;
	var table = layui.table;
	var layer = layui.layer;
	var laydate = layui.laydate;
	var upload = layui.upload;
	
	
	var lay_filter = 'tpl_outlink_category' + outlink_category_id;
	form.val(lay_filter, outlink_category_form_value);

	// 监听提交
	form.on('submit(submit_outlink_category)', function(data) {
		var field = data.field;
		var url = $('form[lay-filter="' + lay_filter + '"]').attr('action');
		if(field.outlink_category_name == '') {
			layer.msg('分类名称必须填写', {
				icon: 2,
				amim: 6
			})
			$('input[name="outlink_category_name"]').addClass('.layui-form-danger').focus();
			return false;
		}
		$.post(url, field, function(data) {
			if(data.code == 0) {
				layer.msg('保存成功', {
					icon: 1
				});
				// 关闭当前页 刷新父页
				$('.layui-body .layui-tab[lay-filter="content"] li.layui-this .layui-tab-close').trigger('click');
				$('.layui-body .layui-tab[lay-filter="content"] li[lay-id="outlink_category"]').trigger('click');
				// 父页面点击
				$('.layui-body .layui-tab[lay-filter="content"] li[lay-id="outlink_category_list"]').trigger('click');
				// 表格重载
				table.reload('outlink_category_list');
			} else {
				layer.msg(data.msg, {
					icon: 2,
					anim: 6
				});
			}
		}, 'json')
		return false;
	})

})